package com.liumin.demo.comlink;

import com.liumin.demo.comlink.base.BaseResponse;

import java.util.List;

import io.reactivex.Flowable;
import io.reactivex.Observable;
import okhttp3.MultipartBody;
import retrofit2.http.Field;
import retrofit2.http.FormUrlEncoded;
import retrofit2.http.GET;
import retrofit2.http.Multipart;
import retrofit2.http.POST;
import retrofit2.http.Part;

/**
 * 描述：
 * 时间：2024/11/4 14:26
 * 作者:  Liumin
 */
public interface HttpService {
    String URL_BASE = "https://api.github.com/";
    String HEADER_API_VERSION = "Accept: application/vnd.github.v3+json";

    @GET("query?type=shentong")
    Observable<BaseResponse<List<User>>> getUsers();

    @FormUrlEncoded
    @POST("token/login")
    Flowable<BaseResponse<User>> loginAndToken(@Field("username") String username,
                                               @Field("password") String password,
                                               @Field("terminal") String terminal,
                                               @Field("machineCode") String machineCode);

    @FormUrlEncoded
    @POST("token/login")
    Observable<BaseResponse<User>> login(@Field("username") String username,
                                         @Field("password") String password,
                                         @Field("terminal") String terminal,
                                         @Field("machineCode") String machineCode);

    /**
     * 上传文件
     *
     * @param partList partList
     * @return List<String>
     */
    @Multipart
    @POST("upload/uploadFileMobile")
    Observable<BaseResponse<List<String>>> uploadFiles(@Part() List<MultipartBody.Part> partList);

    /**
     * 单文件上传
     *
     * @param body MultipartBody.Part
     * @return BaseResponse<String>
     */
    @Multipart
    @POST("upload")
    Observable<BaseResponse<String>> uploadFile(@Part MultipartBody.Part body);
}
